package com.liming.user.controller;

import com.liming.common.result.LMResult;
import com.liming.service.http.HttpClient;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liming
 * @date 2025/3/19
 */
@Slf4j
@RestController
@AllArgsConstructor
@Tag(name = "公用接口-Web")
@RequestMapping("/user/index")
public class IndexController {

    private final HttpClient httpClient;

    @Operation(
            summary = "轮播图",
            responses = {
                    @ApiResponse(responseCode = "1", description = "轮播图", content = {
                            @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))
                    })
            }
    )
    @GetMapping("bannerList")
    public LMResult<List<String>> bannerList() {
        List<String> list = new ArrayList<>();
//        Map<String, Object> map = new HashMap<>();
//        map.put("type", "acg");
//        for (int i = 0; i < 5; i++) {
//            String json = httpClient.get("https://v2.xxapi.cn/api/random4kPic", map);
//            String url = JSONUtil.parseObj(json).getStr("data");
//            list.add(url);
//        }
        list.add("https://smart-enjoyer.oss-cn-hangzhou.aliyuncs.com/2025/04/24/ce8770c2-c3b3-4b87-a985-11c2fb3e5ce3.png");
        list.add("https://smart-enjoyer.oss-cn-hangzhou.aliyuncs.com/2025/04/24/e81d085b-bb75-473b-b144-e03eeed529d2.png");
        list.add("https://smart-enjoyer.oss-cn-hangzhou.aliyuncs.com/2025/04/24/f4eddb60-cb9f-4717-8542-b1a419b6144a.png");
        list.add("https://smart-enjoyer.oss-cn-hangzhou.aliyuncs.com/2025/04/24/fbae3cc5-ca00-4e40-9c75-ce961334d879.png");
        return LMResult.success(list);
    }
}
